import requests

from work.bspregion import bspregion

region = [i.get('SHORT_CODE') +'0'*6 for i in bspregion if len(i.get('SHORT_CODE'))==6]
headers ={
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36'
}
regionCode = '530100000000'
data ={
    "txnCommCom": {
        "txnIttChnlId": "C0071234567890987654321",
        "txnIttChnlCgyCode": "BC01C101",
        "tStsTraceId": "123"
    },
    "txnBodyCom": {
        "regnCode": regionCode,
        "handleWay": "0"
    }
}
#

# result = eval(response.text)
# print(eval(result.get('C-Response-Body')).get('list'))

with open('建行部门.json', 'w', encoding='UTF-8') as f:
    myd = {}
    for r in region:
        data.get('txnBodyCom')['regnCode'] = r
        response = requests.post(url='', data=str(data), headers=headers)
        result = eval(response.text)
        myd[r]=eval(result.get('C-Response-Body')).get('list')
    f.write(str(myd))